﻿using FlashGameSite.Manager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FlashGameSite
{
    public partial class FullScreenPlay : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString.AllKeys.Contains("gameid"))
            {
                LoadGame(Convert.ToInt32(Request.QueryString["gameid"]));
            }
        }

        private void LoadGame(int gameId)
        {
            string objectHtml = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"890\" height=\"740\" id=\"{1}\"><param name=\"movie\" value=\"{0}\"><param name=\"quality\" value=\"high\"><param name=\"bgcolor\" value=\"#333399\"><embed src=\"{0}\" quality=\"high\" bgcolor=\"#333399\" width=\"890\" height=\"740\" name=\"{1}\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed></object>";
            string swfPath = "";
            string title = "";
            int likeCount = 0;
            using (FlashGamesDataContext dataContext = new FlashGamesDataContext())
            {
                var result = dataContext.GetGameByID(gameId);
                foreach (var item in result)
                {
                    swfPath = item.SwfFile;
                    title = item.Title;
                    likeCount = item.LikeCount;
                }
            }

            loadSwf.InnerHtml = string.Format(objectHtml, swfPath, title);
            htitle.InnerText = title;
        }
    }
}